package com.yiwannuofulasi.oauth.executor.query;

import com.yiwannuofulasi.oauth.OauthClientDetailsMapstructMapper;
import com.yiwannuofulasi.oauth.OauthModel;
import com.yiwannuofulasi.oauth.gateway.OauthClientDetailsGateway;
import com.yiwannuofulasi.oauth.dto.OauthClientDetailsListByClientNameQry;
import com.yiwannuofulasi.oauth.dto.data.OauthDTO;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author yiwannuofulasi
 * @description TODO
 * @date 2023/4/20 16:40
 * Copyright (c) 2023/4/20 by yiwannuofulasi yiwannuofulasi@163.com, by 新疆兵团勘测设计院（集团）有限公司 All Rights Reserved.
 */
@Component
public class OauthClientDetailsListByClientNameQryExe {

    @Resource
    private OauthClientDetailsGateway oauthClientDetailsGateway;

    public List<OauthDTO> execute(OauthClientDetailsListByClientNameQry oauthClientDetailsListByClientNameQry) {
        String clientName = oauthClientDetailsListByClientNameQry.getClientName();
        List<OauthModel> oauthModels = oauthClientDetailsGateway.queryOauthByClientName(clientName);
        return OauthClientDetailsMapstructMapper.INSTANCE.toOauthDTOlList(oauthModels);
    }
}
